import {ChangeDetectorRef, Component, Input} from '@angular/core';
import {AlertController, NavController, ToastController} from "ionic-angular";
import {JidihttpProvider} from "../../providers/jidihttp/jidihttp";

/**
 * Generated class for the ZuopinmyComponent component.
 *
 * See https://angular.io/api/core/Component for more info on Angular
 * Components.
 */
@Component({
  selector: 'zuopinmy',
  templateUrl: 'zuopinmy.html'
})
export class ZuopinmyComponent {

  @Input() listitemwodezuopin:any;
  constructor(public toastCtrl: ToastController,public navCtrl: NavController,public alerCtrl: AlertController,public jidiProvider:JidihttpProvider,public cdchange:ChangeDetectorRef) {

  }

  querymore(uuid){
    let confirm = this.alerCtrl.create({
      title: '提示！',
      message: '确定要删除作品吗?',
      buttons: [
        {
          text: '取消',
          handler: () => {
            console.log('Disagree clicked');
          }
        },
        {
          text: '确认',
          handler: () => {
            console.log('Agree clicked');
            this.jidiProvider.deleteZuopin(uuid).subscribe(data => {
              if(data['success']){
                this.showToast("请求成功，正在审核...");
              }else{
                this.showToast("删除失败");
              }
            },error => {
              this.showToast("删除失败");
            });
          }
        }
      ]
    });
    confirm.present()
  }

  /** 返回提示 **/
  showToast(position: string) {
    let toast = this.toastCtrl.create({
      message: position,
      duration: 2000,
      position: "bottom"
    });

    toast.present(toast);
  }

}
